<template>
  <el-container>
    <el-main>
      <div class="charging-info">
        <p>终端编号: {{ chargingData.terminalId }}</p>
        <p>订单编号: {{ chargingData.orderNumber }}</p>
        <p>费用: {{ chargingData.amount }} 元</p>
      </div>
      <el-button type="primary" @click="startCharging">启动</el-button>
    </el-main>
  </el-container>
</template>

<script setup>
import { ref, onMounted } from 'vue';
import axios from 'axios';

const chargingData = ref({
  terminalId: '',
  orderNumber: '',
  amount: 0,
});

const startCharging = async () => {
  try {
    const response = await axios.post('/api/charging/start-session', {
      orderNumber: chargingData.value.orderNumber,
    });
    if (response.data.success) {
      alert('充电已启动');
    }
  } catch (error) {
    console.error('Error starting charging:', error);
  }
};

onMounted(() => {
  // 获取充电初始数据
});
</script>
